import { size, v2, v3, Vec3 } from "cc"
import Tools from "../Tools/Tools";
import { HPInfo, } from "./GlobalClass";
import { LevelDataTmp } from "../SystemStorage/StorageTemp";
import EventManager from "../Managers/EventManager";
import { EventTypes } from "../Managers/EventTypes";

/**整个游戏中 的临时存放数据 任意地方可使用*/
export class GlobalTmpData {
    /**重置 整个游戏 的临时数据 */
    public static reset() {
        // ----------框架数据--------
        this.timeScale = 1.0;
        this.Game.isGameRun = false;
        this.Game.isGameOver = false;
        this.Game.gameTime = 0;
        // this.Game.isGuideLv = false;
        this.Game.isGuideFinish = false;
        this.Game.isPause = false;
        // ---------当前游戏-----------
        Tools.clearObj(this.HpData);
        //
        this.HpData = {};

        this.Player.isDeath = false;
        //
        this.UIData.isAutoEnterLv = false;
        //
        this.LvLogoData.reLiveCount = 0;
        this.LvLogoData.tipCount = 0;
        this.LvLogoData.isPass = false;
        //
        this.LvLogoData.enterCount = 0;
        this.LvLogoData.failCount = 0;
        //
        this.LvLogoData.prop1Count = 0;
        this.LvLogoData.prop2Count = 0;
        this.LvLogoData.prop3Count = 0;
        this.LvLogoData.addHpCount = 0;
        //
        this.AnimalData.isTurnMode = false;
        this.AnimalData.isAvgSpdMode = false;
        this.AnimalData.avgSpdCountdown = 0;
        this.AnimalData.passCount = 0;
        this.AnimalData.curLostGold = 0;
        this.AnimalData.curGetGold = 0;
        this.AnimalData.isCombo = false;
        this.AnimalData.comboCount = 0;


    }

    // #region -----------框架中数据-------   
    /**游戏 dt 时间缩放值 */
    public static timeScale = 1.0;

    /**统计游戏数据 */
    public static Game = {
        isGameRun: false,
        isPause: false,
        isGameOver: true,
        isGuideLv: false,
        isGuideFinish: false,
        startTime: 0,       //游戏开始时间(ms)  
        totalTime: 0,       //当前关卡累计运行时长(包括暂停)   s
        gameTime: 0,        //当前关卡累计游戏时长(不包括暂停) s
        endTime: 0,         //结束时间(ms)
        //
        gameLaunchTime: 0,   //游戏启动时间(ms)
    }
    // 设置
    public static Setting = {
        Audio: {
            bgm: true,          //背景音乐
            effect: true,       //音效
            vibration: true,    //震动
        }
    }

    //#endregion

    // #region -----------当前游戏数据-------

    /**存储角色的血量信息 - 用于UI显示*/
    public static HpData: { [uuid: string]: HPInfo } = {}

    //玩家信息
    public static Player = { wpos: v3(), radius: 1, isDeath: false };

    //
    public static UIData = {
        isAutoEnterLv: false,
        isAutoStartPop: false,
    }
    public static CurLv = 1;
    public static CurGuideLv = 1;
    // 当前的关卡数据
    public static CurLevelData: LevelDataTmp = null;
    // 是否为挑战模式
    public static isHardMode = false;


    // 日志记录
    public static LvLogoData = {
        // 关卡难度
        easyType: '',
        // 复活次数
        reLiveCount: 0,
        // 提示次数
        tipCount: 0,
        // 关卡是否通关
        isPass: false,
        // 当前关卡进入次数
        enterCount: 0,
        // 当前关卡失败次数
        failCount: 0,
        // 道具使用次数
        prop1Count: 0,
        prop2Count: 0,
        prop3Count: 0,
        addHpCount: 0,
    }


    // 动物数据
    public static AnimalData = {
        // 是否为转向模式
        isTurnMode: false,
        // 是否为匀速模式
        isAvgSpdMode: false,
        // 倒计时
        avgSpdCountdown: 0,
        // 当前成功移除次数
        passCount: 0,
        // 当前损失
        curLostGold: 0,
        // 获得的收益
        curGetGold: 0,
        // 连击状态
        isCombo: false,
        // 连击次数
        comboCount: 0,
    }

    //#endregion

    // #region -----------分组实验参数
    public static ExptData = {
        // 更新参数
        updateParam: () => {
            EventManager.emit(EventTypes.SDKEvents.UpdateExptParams);
        },
        // 关卡
        expt_stage: undefined, //undefined
        // 体力
        expt_energy: undefined,
    }
    // #endregion

}